package com.dshore.messagecenter.controller.warning;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dshore.messagecenter.log.LogAnnotation;
import com.dshore.messagecenter.model.system.ResponseResult;
import com.dshore.messagecenter.model.system.User;
import com.dshore.messagecenter.model.warning.MrWarningPerson;
import com.dshore.messagecenter.service.warning.WarningPersonService;
import com.dshore.messagecenter.util.Page;
import com.dshore.messagecenter.util.UUIDUtil;




/**
 * 预警人
 * @author Administrator
 *
 */
@Controller
@RequestMapping(value="/warningPerson")
public class WarningPersonController {
	@Autowired
	private WarningPersonService warningPersonService;
	/**
	 * 页面
	 * @return
	 */
	@RequestMapping(value="/toWarningPerson")
	public String module() {
		return "warning/mrWarningPerson";
	}
	/**
	 * 展示预警人员表信息
	 * @param warningPerson
	 * @return
	 */
	@RequestMapping(value="/getWarningPerson",method=RequestMethod.POST)
	@ResponseBody
	public Page<MrWarningPerson> getWarningPerson(@RequestBody MrWarningPerson warningPerson){
		return warningPersonService.queryListAll(warningPerson);
	}
	/**
	 * 获取单个信息
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/getById",method=RequestMethod.POST)
	@ResponseBody
	public MrWarningPerson getById(String id) {
		return warningPersonService.getById(id);
	}
	/**
	 * 新增
	 * @param warningPerson
	 * @return
	 */
	@LogAnnotation(methodType="新增",targetType="预警通知人员",argsName="principal")
	@RequestMapping(value="/addWarningPerson",method=RequestMethod.POST)
	@ResponseBody
	public ResponseResult<Void> addWarningPerson(MrWarningPerson warningPerson) {
		warningPerson.setId(UUIDUtil.getUUId());
		return warningPersonService.addWarningPerson(warningPerson);
	}
	/**
	 * 修改
	 * @param warningPerson
	 * @return
	 */
	@LogAnnotation(methodType="修改",targetType="预警通知人员",argsName="principal")
	@RequestMapping(value="/changeWarningPerson",method=RequestMethod.POST)
	@ResponseBody
	public ResponseResult<Void> changeWarningPerson(MrWarningPerson warningPerson) {
		return warningPersonService.changeWarningPerson(warningPerson);
	}
	/**
	 * 删除
	 * @param ids
	 */
	@LogAnnotation(methodType="删除",targetType="预警通知人员",argsName="ids",fieldName="PRINCIPAL",tableName="T_MR_WARNING_PERSON")
	@RequestMapping(value="/deleteByIds")
	@ResponseBody
	public ResponseResult<Void> deleteByIds (String ids) {
		return  warningPersonService.deleteByIds(ids);
	}
	
	/**
	 * 查询栏目的账号下拉
	 * @return
	 */
	@RequestMapping("/getAccount")
	@ResponseBody
	public List<User> getAccount(){
		return warningPersonService.getAccount();
		
	}
}
